def quicksort(arr):
    if len(arr) < 2:
        return arr
    pivot = arr[0]
    less = [i for i in arr[1:] if i <= pivot]
    greater = [i for i in arr[1:] if i > pivot]
    return quicksort(less) + [pivot] + quicksort(greater)


print(quicksort([10, 5, 2, 3]))

# // JavaScript 实现
# function quicksort(arr) {
#     if (arr.length < 2) {
#         return arr
#     }
#     var pivot = arr[0]
#     arr.shift()
#     var less = arr.filter(i => i <= pivot)
#     var greater = arr.filter(i => i > pivot)
#
#     return [...quicksort(less), pivot, ...quicksort(greater)]
# }
#
# console.log(quicksort([10, 5, 2, 3]))
